First Document

Okay, we are ready to create documentation within our script file.

Let's add documentation to "example/javascript/lib/utilities.js" file as an example. You will have to make sure you have a script file at the root of your application at the specified path or alter the path accordingly relative to the root of your application.

Suppose that this is our utilities.js file:

//utils namespace
var utils = utils || {};

utils.makeCooler = function (string_in) {
    return string_in + 'izzle';
};

utils.makeUncooler = function (string_in) {
    return string_in.replace(/izzle/gi,'');
};

Add comment blocks

Let's add comment blocks with our first Docular documentation and create a "utilities" module and a few classes.

/**
 * @doc module
 * @name utils
 * @description
 *
 * ## Global Utilities
 *
 * This module houses utillities that can be used
 * across the app. There are some pretty cool and
 * uncool methods in this module so check it outizzle.
 *
 * Note, if you do not define the module using @doc module
 * and the @name with the module id, then this page won't exist!!
 */

//utils namespace
var utils = utils || {};

/**
 * @doc function
 * @name utils.global:makeCooler
 * @param  {string} string_in any ol' string
 * @return {string} adds on the 'izzle'
 * @description
 * Man this function is the functionizzle of the heezy for sheezy.
 *
 * In fact, sometimes I like to use it to coolify everything
 * ```js
 * for(var thing in window) {
 *     if(typeof(window[thing]) === "string") {
 *         window[thing] = util.makeCooler(window[thing]);
 *     }
 * }
 * ```
 */
utils.makeCooler = function (string_in) {
    return string_in + 'izzle';
};

/**
 * @doc function
 * @name utils.global:makeUncooler
 * @param  {string} string_in any ol' string
 * @return {string} removes 'izzle'
 * @description
 *
 * Nothin cool about this function...
 *
 */
utils.makeUncooler = function (string_in) {
    return string_in.replace(/izzle/gi,'');
};

Check out the results

View The Rendered Results!

What's Next?

Now you have created your first document so it's time to learn the details of embedding documentation in your files.

Embedding Documentation